package com.chao.lease.common.exception;

import com.chao.lease.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.sound.midi.ControllerEventListener;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    private Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    private Result error(LeaseException e){
        e.printStackTrace();
        return Result.fail(e.getMessage(),e.getCode());
    }
}

















